package com.dcloud.core.datatransfor;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @program: dcloud-platform
 * @ClassName CollData 数据传输对象
 * @description:
 * @author: shijf
 * @create: 2023-04-17 21:53
 * @Version 1.0
 **/
@NoArgsConstructor
@Data
public class MysqlDataTran extends DataTranParent {

    /*
     * 数据源信息
     * */
    @JsonProperty("source")
    private SourceDTO source;


    @NoArgsConstructor
    @Data
    public static class SourceDTO {
        @JsonProperty("version")
        private String version;
        @JsonProperty("connector")
        private String connector;
        @JsonProperty("name")
        private String name;
        @JsonProperty("ts_ms")
        private Long tsMs;
        @JsonProperty("snapshot")
        private String snapshot;
        @JsonProperty("db")
        private String db;
        @JsonProperty("sequence")
        private Object sequence;
        @JsonProperty("table")
        private String table;
        @JsonProperty("server_id")
        private Integer serverId;
        @JsonProperty("gtid")
        private Object gtid;
        @JsonProperty("file")
        private String file;
        @JsonProperty("pos")
        private Integer pos;
        @JsonProperty("row")
        private Integer row;
        @JsonProperty("thread")
        private Object thread;
        @JsonProperty("query")
        private Object query;
    }

    public static void main(String[] args) throws JsonProcessingException {
//        String s = "{\"before\":null,\"after\":{\"id\":2,\"name\":\"22\"},\"source\":{\"version\":\"1.6.4.Final\",\"connector\":\"mysql\",\"name\":\"mysql_binlog_source\",\"ts_ms\":0,\"snapshot\":\"false\",\"db\":\"dcloud_account\",\"sequence\":null,\"table\":\"test\",\"server_id\":0,\"gtid\":null,\"file\":\"\",\"pos\":0,\"row\":0,\"thread\":null,\"query\":null},\"op\":\"r\",\"ts_ms\":1681739476839,\"transaction\":null}";
//
//        ObjectMapper objectMapper = new ObjectMapper();
//        MysqlDataTran collData = objectMapper.readValue(s, MysqlDataTran.class);
//        System.out.println(collData);
        SourceDTO sourceDTO = new SourceDTO();
    }
}